home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / doc / interpreter / audio.tex < prev    next >
Text File  |  1997-08-13  |  5KB  |  99 lines

  1. @c Copyright (C) 1996, 1997 John W. Eaton
  2. @c Written by Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> on 1996/05/14
  3. @c This is part of the Octave manual.
  4. @c For copying conditions, see the file gpl.tex.
  5.  
  6. @node Audio Processing, System Utilities, Image Processing, Top
  7. @chapter Audio Processing
  8.  
  9. Octave provides a few functions for dealing with audio data.  An audio
  10. `sample' is a single output value from an A/D converter, i.e., a small
  11. integer number (usually 8 or 16 bits), and audio data is just a series
  12. of such samples.  It can be characterized by three parameters:  the
  13. sampling rate (measured in samples per second or Hz, e.g. 8000 or
  14. 44100), the number of bits per sample (e.g. 8 or 16), and the number of
  15. channels (1 for mono, 2 for stereo, etc.).
  16.  
  17. There are many different formats for representing such data.  Currently,
  18. only the two most popular, @emph{linear encoding} and @emph{mu-law
  19. encoding}, are supported by Octave.  There is an excellent FAQ on audio
  20. formats by Guido van Rossum <guido@@cwi.nl> which can be found at any
  21. FAQ ftp site, in particular in the directory
  22. @file{/pub/usenet/news.answers/audio-fmts} of the archive site
  23. @code{rtfm.mit.edu}.
  24.  
  25. Octave simply treats audio data as vectors of samples (non-mono data are
  26. not supported yet).  It is assumed that audio files using linear
  27. encoding have one of the extensions @file{lin} or @file{raw}, and that
  28. files holding data in mu-law encoding end in @file{au}, @file{mu}, or
  29. @file{snd}.
  30.  
  31. @deftypefn {Function File} {} lin2mu (@var{x})
  32. If the vector @var{x} represents mono audio data in 8- or 16-bit
  33. linear encoding, @code{lin2mu (@var{x})} is the corresponding mu-law
  34. encoding.
  35. @end deftypefn
  36.  
  37. @deftypefn {Function File} {} mu2lin (@var{x}, @var{bps})
  38. If the vector @var{x} represents mono audio data in mu-law encoding,
  39. @code{mu2lin} converts it to linear encoding.  The optional argument
  40. @var{bps} specifies whether the input data uses 8 bit per sample
  41. (default) or 16 bit.
  42. @end deftypefn
  43.  
  44. @deftypefn {Function File} {} loadaudio (@var{name}, @var{ext}, @var{bps})
  45. Loads audio data from the file @file{@var{name}.@var{ext}} into the
  46. vector @var{x}.  
  47.  
  48. The extension @var{ext} determines how the data in the audio file is
  49. interpreted;  the extensions @file{lin} (default) and @file{raw}
  50. correspond to linear, the extensions @file{au}, @file{mu}, or @file{snd}
  51. to mu-law encoding.
  52.  
  53. The argument @var{bps} can be either 8 (default) or 16, and specifies
  54. the number of bits per sample used in the audio file.
  55. @end deftypefn
  56.  
  57. @deftypefn {Function File} {} saveaudio (@var{name}, @var{x}, @var{ext}, @var{bps})
  58. Saves a vector @var{x} of audio data to the file
  59. @file{@var{name}.@var{ext}}.  The optional parameters @var{ext} and
  60. @var{bps} determine the encoding and the number of bits per sample used
  61. in the audio file (see @code{loadaudio});  defaults are @file{lin} and
  62. 8, respectively.
  63. @end deftypefn
  64.  
  65. The following functions for audio I/O require special A/D hardware and
  66. operating system support.  It is assumed that audio data in linear
  67. encoding can be played and recorded by reading from and writing to
  68. @file{/dev/dsp}, and that similarly @file{/dev/audio} is used for mu-law
  69. encoding.  These file names are system-dependent.  Improvements so that
  70. these functions will work without modification on a wide variety of
  71. hardware are welcome.
  72.  
  73. @deftypefn {Function File} {} playaudio (@var{name}, @var{ext})
  74. @deftypefnx {Function File} {} playaudio (@var{x})
  75. Plays the audio file @file{@var{name}.@var{ext}} or the audio data
  76. stored in the vector @var{x}.
  77. @end deftypefn
  78.  
  79. @deftypefn {Function File} {} record (@var{sec}, @var{sampling_rate})
  80. Records @var{sec} seconds of audio input into the vector @var{x}.  The
  81. default value for @var{sampling_rate} is 8000 samples per second, or
  82. 8kHz.  The program waits until the user types @key{RET} and then
  83. immediately starts to record.
  84. @end deftypefn
  85.  
  86. @deftypefn {Function File} {} setaudio (@var{type})
  87. @deftypefnx {Function File} {} setaudio (@var{type}, @var{value})
  88. Set or display various properties of your mixer hardware.
  89.  
  90. For example, if @code{vol} corresponds to the volume property, you can
  91. set it to 50 (percent) by @code{setaudio ("vol", 50)}.
  92.  
  93. This is an simple experimental program to control the audio hardware
  94. settings.  It assumes that there is a @code{mixer} program which can be
  95. used as @code{mixer @var{type} @var{value}}, and simply executes
  96. @code{system ("mixer @var{type} @var{value}")}.  Future releases might
  97. get rid of this assumption by using the @code{fcntl} interface.
  98. @end deftypefn
  99.